package cn.bsuc.infirmary.service.impl;

import cn.bsuc.infirmary.domain.Student;
import cn.bsuc.infirmary.mapper.StudentMapper;
import cn.bsuc.infirmary.query.QueryObject;
import cn.bsuc.infirmary.service.IStudentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements IStudentService {
    @Autowired
    private StudentMapper studentMapper;

    @Override
    public void save(Student s) {
        studentMapper.insert(s);
    }

    @Override
    public void update(Student s) {
        studentMapper.updateByPrimaryKey(s);
    }

    @Override
    public PageInfo<Student> queryList(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<Student> list = studentMapper.queryList(qo);
        return new PageInfo<Student>(list);
    }
}
